<template>
    <router-view></router-view>
    <van-tabbar route fixed placeholder>
        <van-tabbar-item replace :to="{ name: 'home' }" icon="home-o">首页</van-tabbar-item>
            <van-tabbar-item replace :to="{ name: 'category' }" icon="apps-o">分类</van-tabbar-item>
            <van-tabbar-item replace :to="{ name: 'message' }" icon="chat-o">消息</van-tabbar-item>
            <van-tabbar-item replace :to="{ name: 'cart' }" icon="shopping-cart-o" :badge="CartCount()">购物车</van-tabbar-item>
            <van-tabbar-item replace :to="{ name: 'user' }" icon="user-o">我的</van-tabbar-item>
            </van-tabbar>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { getUser } from './api'
import useUser from './store/user'
import usecart from './store/cart'
const { CartCount } = usecart()
const { user, updateUser } = useUser()
const isShowTabbar = ref(true)

onMounted(() => {
    if (user.isLogin) {
        loadUser()
    }
})

const loadUser = async () => {
    const data = await getUser()
    updateUser({
        isLogin: true,
        usename: data.usename,
        avatar: data.avatar,
    })
}
</script>
<style></style>
